<div class="splitcontentleft">
<% if @department.people.any? %>
  <table class="list people">
    <thead><tr>
      <th><%= l(:label_user) %></th>
      <% if User.current.allowed_people_to?(:edit_people) %>
      <th style="width:15%"></th>
      <% end %>
    </tr></thead>
    <tbody>
    <% @department.people.sort.each do |person| %>
      <tr id="person-<%= person.id %>" class="<%= cycle 'odd', 'even' %>">
        <td class="person"><%= link_to_user person %></td>
        <% if User.current.allowed_people_to?(:edit_people) %>
        <td class="buttons">
          <%= delete_link url_for(:action => "remove_person", :id => @department, :person_id => person), :remote => true %>
        </td>
        <% end %>
      </tr>
    <% end %>
    </tbody>
  </table>
<% else %>
  <p class="nodata"><%= l(:label_no_data) %></p>
<% end %>
</div>

<div class="splitcontentright">
<% people = Person.active.where(:type => 'User').not_in_department(@department).all(:limit => 100) %>
<% if people.any? %>
  <%= form_for(@department, :remote => true, :url => {:action => "add_people", :id => @department},
               :html => {:method => :post, :class => "select-users"}) do |f| %>
    <fieldset><legend><%=l(:label_user_new)%></legend>

    <p><%= label_tag "user_search", l(:label_user_search) %><%= text_field_tag 'user_search', nil %></p>
    <%= javascript_tag "observeSearchfield('user_search', 'people', '#{ escape_javascript url_for(:action => "autocomplete_for_person", :id => @department)}')" %>

    <div id="people">
      <%= principals_check_box_tags 'person_ids[]', people %>
    </div>

    <p><%= submit_tag l(:button_add) %></p>
    </fieldset>
  <% end %>
<% end %>

</div>